<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div class="app">click me</div>

  <script>
    // https://zhuanlan.zhihu.com/p/78113300
    const app = document.querySelector(".app")
    app.onclick = () => {
      console.log("app click")
    }

    function delay(time) {
      const current = new Date().getTime()
      while (new Date().getTime() < current + time) {}
    }

    console.log(1)
    setTimeout(() => {
      console.log(2)
    }, 5000)
    setTimeout(() => {
      console.log(3)
    }, 0)
    console.log(4)

    setTimeout(() => delay(10000), 1000)
  </script>
</body>
</html>
